import config from "@/config"
import http from "@/utils/request"
import qs from "qs";
export default {
	menu: {
		myMenus: {
			url: `${config.API_URL}/getRouters`,
			name: "获取我的菜单",
			get: async function () {
				return await http.get(this.url);
			}
		},
		list: {
			url: `${config.API_URL}/system/menu/list`,
			name: "获取菜单",
			get: async function () {
				return await http.get(this.url);
			}
		}
	},
	configInfo: {
		tenant: {
			url: `${config.API_URL}/config-tenant/`,
			name: "所有租户配置",
			get: async function () {
				return await http.get(this.url);
			},
			put: async function (configCode, configValue) {
				return await http.put(this.url + configCode + '/' + configValue);
			},
		},
		user: {
			url: `${config.API_URL}/config-user/`,
			name: "所有用户配置",
			get: async function (userId) {
				return await http.get(this.url + userId);
			},
			put: async function (userId, params) {
				return await http.put(this.url + userId, params);
			},
			// 当前用户配置
			getMy: async function () {
				return await http.get(this.url + "my");
			},
			putMy: async function (params) {
				return await http.put(this.url + "my", params);
			},
			// 获取用户系统配置
			getUserConfig: async function (code) {
				return await http.get(this.url + "my/" + code);
			},
		},
		list: {
			url: `${config.API_URL}/system/menu/list`,
			name: "获取菜单",
			get: async function () {
				return await http.get(this.url);
			}
		},
		subUserList: {
			url: `${config.API_URL}/user/subUserList`,
			name: "下级用户列表",
			get: async function () {
				return await http.get(this.url);
			}
		}
	},

	dic: {
		tree: {
			url: `${config.API_URL}/system/dict/type/optionselect`,
			name: "查询字典类型列表",
			get: async function () {
				return await http.get(this.url);
			}
		},
		list: {
			url: `${config.API_URL}/system/dict/data/list`,
			name: "字典明细",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		},
		data: {
			url: `${config.API_URL}/system/dict/data`,
			name: "字典明细",
			get: async function (params) {
				return await http.get(`${this.url}/list`, params);
			},
			list: async function () {
				return await http.get(`${this.url}/list`);
			},
			add: async function (params) {// 新增字典类型
				return await http.post(`${this.url}`, params);
			},
			update: async function (params) {// 修改字典类型
				return await http.put(`${this.url}`, params);
			},
			delete: async function (params) {// 删除字典
				return await http.delete(`${this.url}/${params}`);
			},
		},
		get: {
			url: `${config.API_URL}/system/dict/data/type/`,
			name: "获取字典数据",
			get: async function (params) {
				return await http.get(`${this.url}${params}`);
			}
		},
		type: {
			url: `${config.API_URL}/sys-dict`,
			name: '字典类型',
			list: async function () {// 查询字典类型列表
				return await http.get(`${this.url}/type/optionselect`);
			},
			get: async function (params) {// 查询字典类型详细
				return await http.get(`${this.url}/${params}`, {}, { cache: true });
			},
			add: async function (params) {// 新增字典类型
				return await http.post(`${this.url}/type`, params);
			},
			update: async function (params) {// 修改字典类型
				return await http.put(`${this.url}/type`, params);
			},
			delete: async function (params) {// 删除字典类型
				return await http.delete(`${this.url}/type/${params}`);
			},
		}
	},

	//企业详情
	firm: {
		detail: {
			url: `${config.API_URL}/tenant`,
			name: "获取部门列表",
			get: async function () {
				return await http.get(this.url);
			},
			update: async function (params) {
				return await http.post(this.url, params);
			},
		}
	},
	dept: {
		oldList: {
			url: `${config.API_URL}/sys-dept/tree`,
			name: "获取部门列表",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		},
		list: {
			url: `${config.API_URL}/sys-dept/all`,
			name: "获取部门列表",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		},
		detail: {
			url: `${config.API_URL}/sys-dept/`,
			name: "获取部门列表",
			get: async function (deptId) {
				return await http.get(this.url + deptId);
			},
			add: async function (data) {
				return await http.put(this.url, data);
			},
			// 修改
			update: async function (id, params) {
				return await http.post(this.url + id, params);
			},
			// 保存
			delete: async function (id) {
				return await http.delete(this.url + id);
			},
		}
	},
	post: {
		list: {
			url: `${config.API_URL}/sys-post/`,
			name: "获取岗位列表",
			get: async function (params) {
				return await http.get(this.url, params);
			},
			add: async function (data) {
				return await http.put(this.url, data);
			},
			// 修改
			update: async function (id, params) {
				return await http.post(this.url + id, params);
			},
			//获取详情
			detail: async function (id) {
				return await http.get(this.url + id);
			},
			delete: async function (id) {
				return await http.delete(this.url + id);
			},
			all: async function (params) {
				return await http.get(this.url+'all', params);
			},
		},
	},
	user: {
		list: {
			url: `${config.API_URL}/user/`,
			name: "获取用户列表",
			get: async function (params) {
				return await http.get(this.url, params);
			},
			// 新增用户
			add: async function (params) {
				return await http.put(this.url, params);
			},
			// 修改用户
			update: async function (id, params) {
				return await http.post(this.url + id, params);
			},
			// 用户密码重置
			resetPwd: async function (id, params) {
				return await http.post(this.url + 'restPwd/' + id, params);
			},
			//用户状态修改
			changeStatus: async function (userId, status) {
				return await http.post(this.url + 'changeStatus/' + userId + '/' + status);
			},
			//获取用户详情
			detail: async function (deptId) {
				return await http.get(this.url + deptId);
			},
			//获取用户权限
			auth: async function (userId) {
				return await http.get(this.url + 'authRole/' + userId);
			},
			//设置用户权限
			authRole: async function (userId, roleIds) {
				return await http.put(this.url + 'authRole?userId=' + userId + '&roleIds=' + roleIds);
			},
			delete: async function (id) {
				return await http.delete(this.url + id);
			},
			getSaleManList: async function () {
				return await http.get(this.url + 'getSaleManList');
			},
		},
		toForm: {
			url: `${config.API_URL}/UserProperty/transferForm`,
			name: "用户资产转移",
			post: async function (params) {
				return await http.post(this.url, params);
			},
		}
	},
	group: {
		list: {
			url: `${config.API_URL}/user-group/`,
			name: "获取用户组列表",
			get: async function (params) {
				return await http.get(this.url, params);
			},
			// 新增用户
			add: async function (params) {
				return await http.put(this.url, params);
			},
			// 修改用户
			update: async function (id, params) {
				return await http.post(this.url + id, params);
			},
			delete: async function (id) {
				return await http.delete(this.url + id);
			},
			//获取用户详情
			detail: async function (deptId) {
				return await http.get(this.url + deptId);
			},

			//获取该用户组下面的分页用户
			getPageUser: async function (groupId) {
				return await http.get(`${this.url}page/` + groupId);
			},
			//获取该用户组下面的所有用户
			getUser: async function (groupId) {
				return await http.get(`${this.url}users/` + groupId);
			},
			//添加该用户组下面的用户
			addUser: async function (groupId, userId) {
				return await http.put(`${this.url}users/` + groupId + '/' + userId);
			},
			//添加该用户组下面的用户
			deleteUser: async function (groupId, userId) {
				return await http.delete(`${this.url}users/` + groupId + '/' + userId);
			}
		},
		userList: {
			url: `${config.API_URL}/user-group/`,
			name: "获取用户组列表",
			get: async function (groupId) {
				return await http.get(`${this.url}page/`, groupId);
			},
		}
	},
	role: {
		list: {
			url: `${config.API_URL}/sys-role/`,
			name: "获取角色列表",
			get: async function (params) {
				return await http.get(this.url, params);
			},
			// 新增用户
			add: async function (params) {
				return await http.put(this.url, params);
			},
			// 修改用户
			update: async function (id, params) {
				return await http.post(this.url + id, params);
			},
			delete: async function (id) {
				return await http.delete(this.url + id);
			},
			//获取用户详情
			detail: async function (deptId) {
				return await http.get(this.url + deptId);
			},

		},
	},
	menuPermission: {
		url: `${config.API_URL}/sys-menuPermission/menuPermission/`,
		name: "角色菜单权限",
		get: async function (roleId) {
			return await http.get(this.url + roleId);
		},
	},
	menuPermissionEdit: {
		url: `${config.API_URL}/sys-menuPermission/menuPermission/`,
		name: "角色菜单权限",
		put: async function (roleId, params) {
			return await http.put(this.url + roleId, params);
		},
	},

	app: {
		list: {
			url: `${config.API_URL}/system/app/list`,
			name: "应用列表",
			get: async function () {
				return await http.get(this.url);
			}
		}
	},
	log: {
		list: {
			url: `${config.API_URL}/system/log/list`,
			name: "日志列表",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		}
	},
	table: {
		list: {
			url: `${config.API_URL}/system/table/list`,
			name: "表格列管理列表",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		},
		info: {
			url: `${config.API_URL}/system/table/info`,
			name: "表格列管理详情",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		}
	},
	tasks: {
		list: {
			url: `${config.API_URL}/system/tasks/list`,
			name: "系统任务管理",
			get: async function (params) {
				return await http.get(this.url, params);
			}
		}
	},
	sysObject: {
		url: `${config.API_URL}/udo-custom-obj`,
		name: '对象管理器',
		// 对象管理器分页
		get: async function (params) {
			return await http.get(this.url, params);
		},
		post: async function (data, config = {}) {
			//自定义对象管理器新增
			return await http.post(this.url, data, config);
		},
		put: async function (data, config = {}) {
			// 自定义对象管理器修改
			return await http.put(this.url, data, config);
		},
		field: async function (code, config = {}) {
			// 根据对象id返回字段以及类型
			return await http.get(this.url + '/field', { code, value: 'CUSTOM_FIELD' }, config);
		},
		detail: async function (id, config = {}) {
			//对象管理器详情
			return await http.get(this.url + "/" + id, config);
		},
		delete: async function (id) {
			//自定义对象管理器删除
			return await http.delete(this.url + "/" + id);
		}
	},
	sysFieldsObj: {
		url: `${config.API_URL}/udo-field-obj-r`,
		name: '字段和关系',
		// 对象管理器分页
		get: async function (params) {
			return await http.get(this.url, params);
		},
		post: async function (data, config = {}) {
			//自定义对象管理器新增
			return await http.post(this.url, data, config);
		},
		put: async function (data, config = {}) {
			// 自定义对象管理器修改
			return await http.put(this.url, data, config);
		},
		detail: async function (id, config = {}) {
			//对象管理器详情
			return await http.get(this.url + "/" + id, config);
		},
		delete: async function (id) {
			//自定义对象管理器删除
			return await http.delete(this.url + "/" + id);
		}
	},
	sysFieldsWeight: {
		url: `${config.API_URL}/udo-field-weight/`,
		name: '字段权重',
		// 对象管理器分页
		get: async function (params) {
			return await http.get(this.url, params);
		},
		post: async function (data, config = {}) {
			//自定义对象管理器新增
			return await http.post(this.url, data, config);
		},
		list: async function (id) {
			return await http.get(this.url + "getFieldWeightList/" + id);
		},
		delete: async function (id) {
			return await http.delete(this.url + id);
		}
	},
	sysFieldsWeightList: {
		url: `${config.API_URL}/udo-field-weight/getFieldWeightList`,
		name: '字段权重列表',
		// 对象管理器分页
		get: async function (params) {
			return await http.get(this.url + "/" + params.id);
		},
	},
	userSelect: {
		url: `${config.API_URL}/user-select/`,
		name: '用户选项类型',
		// 所有
		get: async function (params) {
			return await http.get(this.url + 'all', params);
		},
		post: async function (data, config = {}) {
			//更新
			return await http.post(this.url + data.selectId, data, config);
		},
		put: async function (data, config = {}) {
			// 新增
			return await http.put(this.url, data, config);
		},
		delete: async function (id) {
			//删除
			return await http.delete(this.url + id);
		}
	},
	userSelectOption: {
		url: `${config.API_URL}/user-select-option/`,
		name: '用户选项列表option',
		// 所有
		get: async function (params) {
			return await http.get(this.url + 'bySelectId/' + params.selectId, params, { cache: true });
		},
		getAll: {
			url: `${config.API_URL}/user-select-option/`,
			name: '列表页不缓存',
			get: async function (params) {
				return await http.get(this.url + 'bySelectId/' + params.selectId, params);
			},
		},
		post: async function (data, config = {}) {
			//更新
			return await http.post(this.url + data.optionId, data, config);
		},
		put: async function (data, config = {}) {
			// 新增
			return await http.put(this.url, data, config);
		},
		delete: async function (id) {
			//删除
			return await http.delete(this.url + id);
		}
	},
	treeAndUser: {
		url: `${config.API_URL}/sys-dept/treeAndUser`,
		name: '部门树和用户',
		get: async function () {
			return await http.get(this.url, {}, { cache: true });
		},
	},
	deptAndUserTree: {
		url: `${config.API_URL}/sys-dept/deptAndUserTree`,
		name: '部门树和用户',
		get: async function () {
			return await http.get(this.url, {}, { cache: true });
		},
	},
	lite: {
		url: `${config.API_URL}/lite-flow`,
		name: '业务流',
		get: async function (params) {
			// 获取列表
			return await http.get(this.url, params);
		},
		post: async function (data) {
			// 业务流保存
			return await http.post(this.url, data);
		},
		put: async function () {
			// 业务流配置全量刷新
			return await http.put(this.url);
		},
	},
	//权限
	scope: {
		url: '/sys-data-scope/',
		name: '权限',
		get: async function (id) {
			return await http.get(this.url + id);
		},
		post: async function (id, data) {
			return await http.post(this.url + id, data);
		},
	},
	printRelate: {
		name: '打印',
		url: `${config.API_URL}/sys-print-relate/queryFields`,
		get: async function (data) {
			return await http.get(this.url, data);
		},
	},
	queryFields: {
		name: '获取打印模板对象集合',
		url: `${config.API_URL}/sys-print-template`,
		get: async function (data) {
			return await http.get(this.url, data);
		},
		post: async function (data) {
			// 新增打印模板
			return await http.post(this.url, data);
		},
		detail: async function (id) {
			return await http.get(this.url + "/" + id);
		},
		put: async function (data) {
			// 编辑打印模板
			return await http.put(this.url, data);
		},
		delete: async function (id) {
			//删除打印模板
			return await http.delete(this.url + "/" + id);
		},
		print: async function (data) {
			return await http.get(this.url + '/print', data);
		},
	},
	timeline: {
		name: '时间轴',
		url: `${config.API_URL}/timeline/`,
		get: async function (bizCode, bizId) {
			return await http.get(this.url + bizCode + '/' + bizId);
		},
	},
	//文件导出权限

	updatePermissions: {
		url: `${config.API_URL}/fs-permission/`,
		name: '权限设置',
		post: async function (fsId,data) {
			return await http.post(this.url + fsId,data);
		},
	},
	//文件管理
	fileManage: {
		url: `${config.API_URL}/fs/dir/`,
		name: '目录列表',
		get: async function (bizKey, bizId) {
			return await http.get(this.url + bizKey + '/' + bizId);
		},
		//创建
		post: async function (bizKey, bizId, data) {
			return await http.post(this.url + bizKey + '/' + bizId, qs.stringify(data));
		},
		//重命名
		put: async function (bizKey, bizId, data) {
			return await http.put(this.url + bizKey + '/' + bizId, qs.stringify(data));
		},
		delete: async function (bizKey, bizId, data) {
			return await http.deleteForm(this.url + bizKey + '/' + bizId, data);
		},


	},
	fileList: {
		url: `${config.API_URL}/fs/file/`,
		name: '文件列表',
		get: async function (bizKey, bizId, params) {
			return await http.get(this.url + bizKey + '/' + bizId, params);
		},
		//上传文件
		post: async function (bizKey, bizId) {
			return await http.post(this.url + bizKey + '/' + bizId);
		},
		delete: async function (fsId) {
			return await http.delete(this.url + fsId);
		}
	},
	fileLook: {
		url: `${config.API_URL}/fs/file/PreviewUrl/`,
		name: '文件预览',
		get: async function (fsId) {
			return await http.get(this.url + fsId);
		},
	},
	//临时bizId
	tempBizId: {
		url: `${config.API_URL}/fs/tempBizId/`,
		name: '文件预览',
		get: async function () {
			return await http.get(this.url);
		},
	},
	//系统打印导出
	sysExport: {
		url: `${config.API_URL}/sys/export/`,
		name: '打印',
		//上传文件
		post: async function (code, params) {
			return await http.post(
				this.url + code,
				params,
				{ responseType: 'blob' }, //必须加，否则可能出现乱码或者文件错误，导致文件无法打开
			);
		},
	},
	//系统打印导出Pdf
	sysExportPdf: {
		url: `${config.API_URL}/sys/exportPdf/`,
		name: '打印',
		//上传文件
		post: async function (code, params) {
			return await http.post(
				this.url + code,
				params,
				{ responseType: 'blob' }, //必须加，否则可能出现乱码或者文件错误，导致文件无法打开
				{ "Content-Type": "application/pdf" },
				{ " Content-Disposition": "attachment" },
			);
		},
	},
	changePwd: {
		url: `${config.API_URL}/profile/changePwd/`,
		name: '密码修改',
		post: async function (data) {
			return await http.post(this.url, qs.stringify(data));
		},
	},
	sysLogRecord: {
		url: `${config.API_URL}/sys-log-record/`,
		name: '系统日志',
		get: async function (params) {
			return await http.get(this.url, params);
		},
	}
}
